<{include file="app/header.tpl"}>

<form class="release-show fix" action="/show/release_post" method="POST" onsubmit="return enter_submit_show();">
    <div class="left">
        <img src="<{$imagepath}>" class="img" alt="">
    </div>
    <div class="middle">
        <textarea name="comments" onKeyUp="writeWbTxt(this)" onChange="writeWbTxt(this)" placeholder="说说你和这件小物的故事" class="text"></textarea>
    </div>
    <span class="zishu">还可以输入140字</span>
    <input type="hidden" type="text" id="uid" name="uid" value="<{$uid}>"> 
    <input type="hidden" type="text" id="orderid" name="orderid" value="<{$orderId}>"> 
    <input type="hidden" type="text" id="orderno" name="orderno" value="<{$orderNo}>"> 
    <input type="hidden" type="text" id="imagepath" name="imagepath" value="<{$imagepath}>"> 

    <input class="submit" type="submit" name="submit_op" onclick="return submit_address();" value="我要晒单">
</form>

<script>

var uid = <{$uid}>;
var orderId = <{$orderId}>;
var imagepath = '<{$imagepath}>';

function enter_submit_show() {
    var num = checkWbTxt(obj);
    if (num <= 0) {
        return false;
    }
}

function writeWbTxt(obj) {
    var num = checkWbTxt(obj);
    if (num >= 0) {
        $('.zishu').html('还可以输入' + num + '字');
    } else {
        $('.zishu').html('已超出' + Math.abs(num) + '字').css('color', '#f00');
    }
}

function checkWbTxt(obj) {
    var val = obj.value;
    var len = val.length;
    //汉字和全角占两个字符 
    var addLen = (val.match(/[^\x00-\xff]|[\u4E00-\u9FA5]/g) || '').length;
    var num = 140 - Math.ceil((len + addLen) / 2);
    return num;
}

</script>

<{include file="app/footer.tpl"}>
